package com.xingda.packing.rule.shunt;

import com.xingda.packing.domain.ProductBox;
import com.xingda.packing.domain.Wheel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class WheelTagShunt implements ShuntService {
    @Override
    public boolean canShunt(ProductBox productBox, Wheel wheel) {
        boolean result = can(productBox, wheel);
        if (!result) {
            log.info("box:{}, 工字轮条码：{}，工字轮型号{}->{}", productBox.getBoxNo(), wheel.getBarCode(), productBox.getWheelTag(), false);
        }
        return result;
    }

    private boolean can(ProductBox productBox, Wheel wheel) {
        if (productBox.isCustomer()) {
            return productBox.getWheelTag().equals(wheel.getWheelTag()) && productBox.getConsumerName().equals(wheel.getConsumerName());
        }
        return productBox.getWheelTag().equals(wheel.getWheelTag());
    }
}
